package com.thundersoft.mm;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.util.Log;

import com.thundersoft.mm.phone.ConnectionManager;
import com.thundersoft.mm.phone.Wifi.WifiP2pSocket;

import org.json.JSONObject;

import java.io.File;
import java.util.HashMap;


public class FileActivity extends Activity {
    private String ip = "192.168.43.121";
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ConnectionManager.init(getApplicationContext());
    }

    @Override
    protected void onResume() {
        super.onResume();
        handler.sendEmptyMessageDelayed(0,5000);
        handler.sendEmptyMessageDelayed(1,1000);
    }

    Handler handler = new Handler(){
        @Override
        public void dispatchMessage(Message msg) {
//            if (ConnectionManager.btTextMsgListener.connected
//                    && ConnectionManager.mGlassesIp != null) {
//                    FileTransfer fileTransfer = new FileTransfer(file.getName(),
//                            file.length());
//                    fileTransfer.setFilePath(file.getAbsolutePath());
//                    WifiP2pSocket.transfer(fileTransfer,ConnectionManager.mGlassesIp);
//            }




//            JSONObject o = new JSONObject();
//            o.put("type",String.valueOf(4));
//            ConnectionManager.btTextMsgListener.sendMsg(o.toString().getBytes());


/*

            */

        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ConnectionManager.release();
    }
}
